//
//  BCSafeCenterFingerPrintLoginCell.m
//  GSBlockChain
//
//  Created by guoshikeji_a on 2018/11/26.
//  Copyright © 2018 guoshikeji. All rights reserved.
//

#import "BCSafeCenterFingerPrintLoginCell.h"

@interface BCSafeCenterFingerPrintLoginCell ()

@property (nonatomic, strong) UISwitch *fingerSwitch;

/**
 *switchButton
 */
@property (nonatomic, strong) QMUIButton *swithButton;

@end

@implementation BCSafeCenterFingerPrintLoginCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.fingerSwitch = [UISwitch new];
        [self.contentView addSubview:self.fingerSwitch];
        [self.fingerSwitch mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(self.contentView).offset(-15.0);
            make.centerY.mas_equalTo(self.contentView);
        }];
        //
        [self.fingerSwitch setUserInteractionEnabled:false];
        
        //
        self.swithButton = [QMUIButton new];
        [self.contentView addSubview:self.swithButton];
        [self.swithButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.mas_equalTo(self.fingerSwitch);
        }];
        //
        [self.swithButton addTarget:self action:@selector(swithButtonDidClickedAction) forControlEvents:UIControlEventTouchUpInside];
    }
    return self;
}

- (void)setCellModel:(BCSafeCenterCellModel *)cellModel {
    [super setCellModel:cellModel];
    //
    self.fingerSwitch.on = [BCUserManager sharedUser].isOpenLocalAuthentication;
}


#pragma mark - swithButtonDidClickedAction
- (void)swithButtonDidClickedAction {
    if (self.delegate && [self.delegate respondsToSelector:@selector(safeCenterCell:fingerSwitch:fingerButtin:)]) {
        [self.delegate safeCenterCell:self fingerSwitch:self.fingerSwitch fingerButtin:self.swithButton];
    }
}


@end
